<?php
declare(strict_types=1);

namespace App\Task;

use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Crontab\Annotation\Crontab;
use Hyperf\DbConnection\Db;

/**
 * 每天执行一次
 * 生成一条默认的统计数据
 */
class StautoTask 
{
    /**
     * 执行方法
     * [execute description]
     * @return [type] [description]
     */
    public function execute()
    {
        $today = date("Y-m-d");
        $exists = Db::table('statis_record')
            ->where(['tag'=>"gzh_sub","date"=>$today])
            ->first();

        if(empty($exists)){
            $save_data = [
                'tag'=>"gzh_sub",
                'type'=>"sub",
                'date'=>$today,
                'created_at'=>time()
            ];
            Db::table('statis_record')
                ->insert($save_data);
        }
    }
}
